Set a reasonable default height for the window.
authorOwen Taylor <otaylor@redhat.com>
Fri, 2 Nov 2001 00:25:14 +0000 (00:25 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 2 Nov 2001 00:25:14 +0000 (00:25 +0000)
Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>

* demos/gtk-demo/stock_browser.c (do_stock_browser):
Set a reasonable default height for the window.

* demos/gtk-demo/stock_browser.c (id_to_macro): Fix
bug where subsequent '-' weren't converted to '_'.
(#59550, Matthias Clasen)

* demos/gtk-demo/appwindow.c (menu_items): Don't right
justify the Help menu - just include a comment on
how to do it. (#63539,  Marius Andreiana)

* gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't
list GTK_ICON_SIZE_INVALID.

* demos/gtk-demo/stock_browser.c: Show the biggest available
size, not a fixed size. (Often reported, including #63539,
Marius Andreiana)

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
demos/gtk-demo/appwindow.c
demos/gtk-demo/stock_browser.c
gtk/gtkiconfactory.c

index 3ca35f91bca948415794e65e9085638967b19104..b8f1628f9e3879aef6ccfd0b16b53376c9f46f4d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * demos/gtk-demo/stock_browser.c (do_stock_browser): 
+       Set a reasonable default height for the window.
+
+       * demos/gtk-demo/stock_browser.c (id_to_macro): Fix
+       bug where subsequent '-' weren't converted to '_'.
+       (#59550, Matthias Clasen)
+
+       * demos/gtk-demo/appwindow.c (menu_items): Don't right 
+       justify the Help menu - just include a comment on
+       how to do it. (#63539,  Marius Andreiana)
+
+       * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't 
+       list GTK_ICON_SIZE_INVALID.
+
+       * demos/gtk-demo/stock_browser.c: Show the biggest available
+       size, not a fixed size. (Often reported, including #63539, 
+       Marius Andreiana)
+
 Thu Nov  1 19:11:35 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkrbtree.c (gtk_rbtree_reorder_fixup): Fix reorder_fixup,
index 3ca35f91bca948415794e65e9085638967b19104..b8f1628f9e3879aef6ccfd0b16b53376c9f46f4d 100644 (file)
@@ -1,3 +1,23 @@
+Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * demos/gtk-demo/stock_browser.c (do_stock_browser): 
+       Set a reasonable default height for the window.
+
+       * demos/gtk-demo/stock_browser.c (id_to_macro): Fix
+       bug where subsequent '-' weren't converted to '_'.
+       (#59550, Matthias Clasen)
+
+       * demos/gtk-demo/appwindow.c (menu_items): Don't right 
+       justify the Help menu - just include a comment on
+       how to do it. (#63539,  Marius Andreiana)
+
+       * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't 
+       list GTK_ICON_SIZE_INVALID.
+
+       * demos/gtk-demo/stock_browser.c: Show the biggest available
+       size, not a fixed size. (Often reported, including #63539, 
+       Marius Andreiana)
+
 Thu Nov  1 19:11:35 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkrbtree.c (gtk_rbtree_reorder_fixup): Fix reorder_fixup,
index 3ca35f91bca948415794e65e9085638967b19104..b8f1628f9e3879aef6ccfd0b16b53376c9f46f4d 100644 (file)
@@ -1,3 +1,23 @@
+Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * demos/gtk-demo/stock_browser.c (do_stock_browser): 
+       Set a reasonable default height for the window.
+
+       * demos/gtk-demo/stock_browser.c (id_to_macro): Fix
+       bug where subsequent '-' weren't converted to '_'.
+       (#59550, Matthias Clasen)
+
+       * demos/gtk-demo/appwindow.c (menu_items): Don't right 
+       justify the Help menu - just include a comment on
+       how to do it. (#63539,  Marius Andreiana)
+
+       * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't 
+       list GTK_ICON_SIZE_INVALID.
+
+       * demos/gtk-demo/stock_browser.c: Show the biggest available
+       size, not a fixed size. (Often reported, including #63539, 
+       Marius Andreiana)
+
 Thu Nov  1 19:11:35 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkrbtree.c (gtk_rbtree_reorder_fixup): Fix reorder_fixup,
index 3ca35f91bca948415794e65e9085638967b19104..b8f1628f9e3879aef6ccfd0b16b53376c9f46f4d 100644 (file)
@@ -1,3 +1,23 @@
+Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * demos/gtk-demo/stock_browser.c (do_stock_browser): 
+       Set a reasonable default height for the window.
+
+       * demos/gtk-demo/stock_browser.c (id_to_macro): Fix
+       bug where subsequent '-' weren't converted to '_'.
+       (#59550, Matthias Clasen)
+
+       * demos/gtk-demo/appwindow.c (menu_items): Don't right 
+       justify the Help menu - just include a comment on
+       how to do it. (#63539,  Marius Andreiana)
+
+       * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't 
+       list GTK_ICON_SIZE_INVALID.
+
+       * demos/gtk-demo/stock_browser.c: Show the biggest available
+       size, not a fixed size. (Often reported, including #63539, 
+       Marius Andreiana)
+
 Thu Nov  1 19:11:35 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkrbtree.c (gtk_rbtree_reorder_fixup): Fix reorder_fixup,
index 3ca35f91bca948415794e65e9085638967b19104..b8f1628f9e3879aef6ccfd0b16b53376c9f46f4d 100644 (file)
@@ -1,3 +1,23 @@
+Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * demos/gtk-demo/stock_browser.c (do_stock_browser): 
+       Set a reasonable default height for the window.
+
+       * demos/gtk-demo/stock_browser.c (id_to_macro): Fix
+       bug where subsequent '-' weren't converted to '_'.
+       (#59550, Matthias Clasen)
+
+       * demos/gtk-demo/appwindow.c (menu_items): Don't right 
+       justify the Help menu - just include a comment on
+       how to do it. (#63539,  Marius Andreiana)
+
+       * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't 
+       list GTK_ICON_SIZE_INVALID.
+
+       * demos/gtk-demo/stock_browser.c: Show the biggest available
+       size, not a fixed size. (Often reported, including #63539, 
+       Marius Andreiana)
+
 Thu Nov  1 19:11:35 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkrbtree.c (gtk_rbtree_reorder_fixup): Fix reorder_fixup,
index 3ca35f91bca948415794e65e9085638967b19104..b8f1628f9e3879aef6ccfd0b16b53376c9f46f4d 100644 (file)
@@ -1,3 +1,23 @@
+Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * demos/gtk-demo/stock_browser.c (do_stock_browser): 
+       Set a reasonable default height for the window.
+
+       * demos/gtk-demo/stock_browser.c (id_to_macro): Fix
+       bug where subsequent '-' weren't converted to '_'.
+       (#59550, Matthias Clasen)
+
+       * demos/gtk-demo/appwindow.c (menu_items): Don't right 
+       justify the Help menu - just include a comment on
+       how to do it. (#63539,  Marius Andreiana)
+
+       * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't 
+       list GTK_ICON_SIZE_INVALID.
+
+       * demos/gtk-demo/stock_browser.c: Show the biggest available
+       size, not a fixed size. (Often reported, including #63539, 
+       Marius Andreiana)
+
 Thu Nov  1 19:11:35 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkrbtree.c (gtk_rbtree_reorder_fixup): Fix reorder_fixup,
index 3ca35f91bca948415794e65e9085638967b19104..b8f1628f9e3879aef6ccfd0b16b53376c9f46f4d 100644 (file)
@@ -1,3 +1,23 @@
+Thu Nov  1 19:18:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * demos/gtk-demo/stock_browser.c (do_stock_browser): 
+       Set a reasonable default height for the window.
+
+       * demos/gtk-demo/stock_browser.c (id_to_macro): Fix
+       bug where subsequent '-' weren't converted to '_'.
+       (#59550, Matthias Clasen)
+
+       * demos/gtk-demo/appwindow.c (menu_items): Don't right 
+       justify the Help menu - just include a comment on
+       how to do it. (#63539,  Marius Andreiana)
+
+       * gtk/gtkiconfactory.c (gtk_icon_set_get_sizes): Don't 
+       list GTK_ICON_SIZE_INVALID.
+
+       * demos/gtk-demo/stock_browser.c: Show the biggest available
+       size, not a fixed size. (Often reported, including #63539, 
+       Marius Andreiana)
+
 Thu Nov  1 19:11:35 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkrbtree.c (gtk_rbtree_reorder_fixup): Fix reorder_fixup,
index 89b517c07f6448fc61112b3975bd5d976810aab0..c052bcbc608ae9d8180b42dfbb1725ecb8a0b551 100644 (file)
@@ -52,7 +52,10 @@ static GtkItemFactoryEntry menu_items[] =
   { "/_Preferences/Shape/_Rectangle",   NULL, menuitem_cb, 0, "/Preferences/Shape/Square" },
   { "/_Preferences/Shape/_Oval",        NULL, menuitem_cb, 0, "/Preferences/Shape/Rectangle" },
 
-  { "/_Help",            NULL,         0,                     0, "<LastBranch>" },
+  /* If you wanted this to be right justified you would use "<LastBranch>", not "<Branch>".
+   * Right justified help menu items are generally considered a bad idea now days.
+   */
+  { "/_Help",            NULL,         0,                     0, "<Branch>" },
   { "/Help/_About",      NULL,         menuitem_cb,       0 },
 };
 
index 4523d699a7761713048c864f66917587bf4bae5d..7457c5f1729f1dddcba3cd29bb873ef06eff1ac0 100644 (file)
@@ -84,26 +84,32 @@ struct _StockItemDisplay
 static gchar*
 id_to_macro (const gchar *id)
 {
-  GString *macro;
+  GString *macro = NULL;
   const gchar *cp;
 
-  /* gtk-foo -> GTK_STOCK_FOO */
-  
-  cp = id;
-  while (*cp && *cp != '-')
-    ++cp;
-
-  if (*cp == '\0')
-    return g_strdup ("??UNKNOWN??");
+  /* gtk-foo-bar -> GTK_STOCK_FOO_BAR */
 
   macro = g_string_new (NULL);
   
-  g_string_append_len (macro, id, cp - id);
+  cp = id;
   
-  g_string_append (macro, "_STOCK");
-  g_string_append (macro, cp);
+  if (strncmp (cp, "gtk-", 4) == 0)
+    {
+      g_string_append (macro, "GTK_STOCK_");
+      cp += 4;
+    }
 
-  g_string_ascii_up (macro);
+  while (*cp)
+    {
+      if (*cp == '-')
+       g_string_append_c (macro, '_');
+      else if (g_ascii_islower (*cp))
+       g_string_append_c (macro, g_ascii_toupper (*cp));
+      else
+       g_string_append_c (macro, *cp);
+
+      cp++;
+    }
 
   return g_string_free (macro, FALSE);
 }
@@ -220,6 +226,38 @@ create_model (void)
   return GTK_TREE_MODEL (store);
 }
 
+/* Finds the largest size at which the given image stock id is
+ * available. This would not be useful for a normal application
+ */
+static GtkIconSize
+get_largest_size (const char *id)
+{
+  GtkIconSet *set = gtk_icon_factory_lookup_default (id);
+  GtkIconSize *sizes;
+  gint n_sizes, i;
+  GtkIconSize best_size = GTK_ICON_SIZE_INVALID;
+  gint best_pixels = 0;
+
+  gtk_icon_set_get_sizes (set, &sizes, &n_sizes);
+
+  for (i = 0; i < n_sizes; i++)
+    {
+      gint width, height;
+      
+      gtk_icon_size_lookup (sizes[i], &width, &height);
+
+      if (width * height > best_pixels)
+       {
+         best_size = sizes[i];
+         best_pixels = width * height;
+       }
+    }
+  
+  g_free (sizes);
+
+  return best_size;
+}
+
 static void
 selection_changed (GtkTreeSelection *selection)
 {
@@ -263,12 +301,9 @@ selection_changed (GtkTreeSelection *selection)
           gtk_label_set_text (GTK_LABEL (display->label_accel_label), "");
         }
 
-      /* The problem here is that some icons don't have SIZE_LARGE_TOOLBAR,
-       * so we get a "missing image" icon...
-       */
       if (info->small_icon)
         gtk_image_set_from_stock (GTK_IMAGE (display->icon_image), info->id,
-                                  GTK_ICON_SIZE_LARGE_TOOLBAR);
+                                  get_largest_size (info->id));
       else
         gtk_image_set_from_pixbuf (GTK_IMAGE (display->icon_image), NULL);
 
@@ -403,6 +438,7 @@ do_stock_browser (void)
 
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_window_set_title (GTK_WINDOW (window), "Stock Icons and Items");
+      gtk_window_set_default_size (GTK_WINDOW (window), -1, 500);
 
       g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
       gtk_container_set_border_width (GTK_CONTAINER (window), 8);
index 09de30d2464611187306cc03ed8a01f553c5787a..2c62650e8e0b9deef83eb454d910af147d81c932 100644 (file)
@@ -1305,12 +1305,12 @@ gtk_icon_set_get_sizes (GtkIconSet   *icon_set,
       init_icon_sizes ();
       
       *sizes = g_new (GtkIconSize, icon_sizes_used);
-      *n_sizes = icon_sizes_used;
+      *n_sizes = icon_sizes_used - 1;
       
-      i = 0;      
+      i = 1;      
       while (i < icon_sizes_used)
         {
-          (*sizes)[i] = icon_sizes[i].size;
+          (*sizes)[i - 1] = icon_sizes[i].size;
           ++i;
         }
     }